import 'package:zfth/pages/home/homegrid/HomeGridLogic.dart';
import 'package:zfth/pages/home/homegrid/HomeGridState.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'HomeCountLogic.dart';
import 'HomeCountState.dart';

class HomeCountPage extends StatelessWidget{
  const HomeCountPage({super.key});


  @override
  Widget build(BuildContext context) {
    final HomeCountState state = Get.find<HomeCountLogic>().state;
    return GetBuilder<HomeCountLogic>(
        builder: (logic){

          return Column(
            children: [

              Padding(
                padding: const EdgeInsets.all(10),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                      child: GestureDetector(
                        onTap: (){
                          Get.toNamed("/eq/allEqList");
                        },
                        child: Container(
                          // margin: const EdgeInsets.only(right: 5.0),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(12.0),
                          ),
                          padding: const EdgeInsets.all(16.0),
                          child: Stack(
                            children: [
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  const Text('终端总数',),
                                  // const SizedBox(height: 5.0), // 行间距
                                  Text('${state.count["totalCount"]}',style: TextStyle( fontSize: 24),),
                                ],
                              ),
                              Positioned(
                                right: 0,
                                top: 0,
                                child: Image.asset("images/xinpian.png",width: 20,height: 20,fit:BoxFit.contain),

                              )
                            ],
                          ),
                        ),
                      )

                    ),
                    // 第二个圆角框


                  ],
                ),
              ),

              Padding(
                padding: const EdgeInsets.only(left: 10,right: 10),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                        child: GestureDetector(
                          onTap: (){
                            Get.toNamed("/eq/onLineEqList");
                          },
                          child: Container(
                              margin: const EdgeInsets.only(right: 5.0),
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.circular(12.0),
                              ),
                              padding: const EdgeInsets.all(16.0),
                              child: Stack(
                                children: [
                                  Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      const Text('在线终端'),
                                      // const SizedBox(height: 5.0), // 行间距
                                      Text("${state.count['onLineCount']}", style: TextStyle(fontSize: 24),),
                                    ],
                                  ),
                                  Positioned(
                                    right: 0,
                                    top: 0,
                                    child: Image.asset("images/xinhao.png",width: 20,height: 20,fit:BoxFit.contain),

                                  )
                                ],
                              )
                          ),
                        )
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: (){
                          Get.toNamed("/eq/offLineEqList");

                        },
                        child:  Container(
                          // margin: const EdgeInsets.only(right: 5.0),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(12.0),
                          ),
                          padding: const EdgeInsets.all(16.0),
                          child: Stack(
                            children: [
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  const Text('离线终端',),
                                  // const SizedBox(height: 5.0), // 行间距
                                  Text('${state.count["offLineCount"]}',style: TextStyle( fontSize: 24),),
                                ],
                              ),
                              Positioned(
                                right: 0,
                                top: 0,
                                child: Image.asset("images/lixian2.png",width: 20,height: 20,fit:BoxFit.contain),


                              )
                            ],
                          ),
                        ),

                      )

                    ),
                    // 第二个圆角框
                    // Expanded(
                    //   child: GestureDetector(
                    //     onTap: (){
                    //       Get.toNamed("/eq/faultEqList");
                    //     },
                    //     child: Container(
                    //         margin: const EdgeInsets.only(left: 5.0),
                    //         decoration: BoxDecoration(
                    //           color: Colors.white,
                    //           borderRadius: BorderRadius.circular(12.0),
                    //         ),
                    //         padding: const EdgeInsets.all(16.0),
                    //         child: Stack(
                    //           children: [
                    //             Column(
                    //               crossAxisAlignment: CrossAxisAlignment.start,
                    //               children: [
                    //                 const Text('故障设备'),
                    //                 // const SizedBox(height: 5.0), // 行间距
                    //                 Text("${state.count['faultCount']}", style: TextStyle(fontSize: 24),),
                    //               ],
                    //             ),
                    //             Positioned(
                    //               right: 0,
                    //               top: 0,
                    //               child: Image.asset("images/guzhang.png",width: 20,height: 20,fit:BoxFit.contain),
                    //
                    //             )
                    //           ],
                    //         )
                    //     ),
                    //   ),
                    // ),

                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(left: 10,right: 10),
                child: Column(
                  children: [
                    Container(
                      padding: const EdgeInsets.all(10),
                      width: double.infinity,
                      child: const Text("报警统计",textAlign:TextAlign.start,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),),
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Expanded(
                            child: GestureDetector(
                              onTap: (){

                              },
                              child:  Container(
                                margin: const EdgeInsets.only(right: 5.0),
                                decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.circular(12.0),
                                ),
                                padding: const EdgeInsets.all(16.0),
                                child: Stack(
                                  children: [
                                    Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        const Text('温湿度报警',),
                                        // const SizedBox(height: 5.0), // 行间距
                                        Text('${state.count["alarmThCount"]}',style: TextStyle( fontSize: 24),),
                                      ],
                                    ),
                                    Positioned(
                                      right: 0,
                                      top: 0,
                                      child: Image.asset("images/baojing.png",width: 20,height: 20,fit:BoxFit.contain),


                                    )
                                  ],
                                ),
                              ),

                            )

                        ),
                        // 第二个圆角框
                        Expanded(
                          child: GestureDetector(
                            onTap: (){

                            },
                            child: Container(
                                margin: const EdgeInsets.only(left: 5.0),
                                decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.circular(12.0),
                                ),
                                padding: const EdgeInsets.all(16.0),
                                child: Stack(
                                  children: [
                                    Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        const Text('趋势报警'),
                                        // const SizedBox(height: 5.0), // 行间距
                                        Text("${state.count['alarmTrendCount']}", style: TextStyle(fontSize: 24),),
                                      ],
                                    ),
                                    Positioned(
                                      right: 0,
                                      top: 0,
                                      child: Image.asset("images/qushi.png",width: 20,height: 20,fit:BoxFit.contain),

                                    )
                                  ],
                                )
                            ),
                          ),
                        ),

                      ],
                    ),

                  ],
                ),
              ),

              Padding(
                padding: const EdgeInsets.all(10),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                        child: GestureDetector(
                          onTap: (){

                          },
                          child:  Container(
                            margin: const EdgeInsets.only(right: 5.0),
                            decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(12.0),
                            ),
                            padding: const EdgeInsets.all(16.0),
                            child: Stack(
                              children: [
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    const Text('烟感报警',),
                                    // const SizedBox(height: 8.0), // 行间距
                                    Text('${state.count["alarmSmokeCount"]}',style: TextStyle( fontSize: 24),),
                                  ],
                                ),
                                Positioned(
                                  right: 0,
                                  top: 0,
                                  child: Image.asset("images/yanhuo.png",width: 20,height: 20,fit:BoxFit.contain),


                                )
                              ],
                            ),
                          ),

                        )

                    ),


                  ],
                ),
              ),

            ],

          );


        }

    );
  }

}